﻿document.getElementById('quizForm').addEventListener('submit', function(e) {
  e.preventDefault();
  const form = e.target;
  const values = [
    parseInt(form.q1.value),
    parseInt(form.q2.value),
    parseInt(form.q3.value),
    parseInt(form.q4.value),
    parseInt(form.q5.value),
    parseInt(form.q6.value),
    parseInt(form.q7.value),
    parseInt(form.q8.value),
    parseInt(form.q9.value),
    parseInt(form.q10.value)
  ];

  const total = values.reduce((sum, val) => sum + val, 0);

  let personality, description, suggestion;

  if (total >= 36) {
    personality = "曾国藩型";
    description = "守拙耐烦，稳重可靠。你如曾国藩般坚守底线、重信守诺，是团队的定海神针。";
    suggestion = "警惕固执，建议练习柔性沟通，提升适应力。";
  } else if (total >= 32) {
    personality = "范仲淹型";
    description = "先忧后乐，顾全大局。你心怀集体，信义为先，是组织的远见者。";
    suggestion = "警惕被误解为圆滑，需守住底线原则。";
  } else if (total >= 28) {
    personality = "王阳明型";
    description = "知行合一，逆境觉醒。你情绪稳定，目光长远，是变革的推动者。";
    suggestion = "避免理想脱离现实，建议小步验证想法。";
  } else if (total >= 24) {
    personality = "范蠡型";
    description = "功成身退，顺势而化。你懂得取舍，定力深厚，是智慧的隐者。";
    suggestion = "警惕“功成即退”，需学习守成智慧。";
  } else {
    personality = "诸葛型";
    description = "沉潜修炼，志存高远。你如青年诸葛亮，静待时机，厚积薄发。";
    suggestion = "避免自我怀疑，主动寻找“小战场”验证价值。";
  }

  document.getElementById('personality').textContent = personality;
  document.getElementById('description').textContent = description;
  document.getElementById('suggestion').textContent = suggestion;

  // 隐藏表单，显示结果
  document.getElementById('quizForm').style.display = 'none';
  document.getElementById('result').style.display = 'block';

  // 升级入口点击事件
  document.querySelector('.join-btn').addEventListener('click', function(e) {
    e.preventDefault();
    alert("如需参与完整30题测评，请联系【职场修心社】获取入口。");
  });
});